Skip to content

feat: framework-agnostic runSelfUpdate helper#2

Merged
kreneskyp merged 1 commit into
mainfrom
feat/self-update-helper
Jun 20, 2026
Merged

feat: framework-agnostic runSelfUpdate helper#2
kreneskyp merged 1 commit into
mainfrom
feat/self-update-helper

Conversation

@kreneskyp

Copy link
Copy Markdown
Contributor

What

Adds a reusable `runSelfUpdate` helper so any npm-distributed IX CLI can offer an `update`/install-latest command without re-implementing the registry query, version comparison, and global install.

```ts
runSelfUpdate({ packageName, currentVersion, header?, registry?, check? }): Promise<{ updated, latest }>
```

  • `npm view version` → compare to `currentVersion` → `npm install -g @` (unless `check`).
  • Framework-agnostic: no oclif dependency, callable from a plain async dispatcher (e.g. quoin's `update`) as readily as from `BaseCommand`.
  • Renders through `@agent-ix/ix-ui-cli` (same `Listing`/`FlowLine`/`Note` surface as the other command runners) and also returns `SelfUpdateResult` for callers that branch.

Registry resolution

Defaults to the ambient npm config — i.e. however the caller was installed (its `@scope:registry`, or the npm default) — rather than a hardcoded registry. When a `registry` override is supplied it is applied as the scope-specific `--:registry=` flag for a scoped package, because a plain `--registry` is silently ignored for a scoped package when an npmrc pins a `@scope:registry`. Unscoped packages use a plain `--registry`.

Spec

  • New FR-023 (`spec/functional/FR-023-self-update-helper.md`, implements StR-003) + index/log.
  • AC→test traceability added to `spec/tests.md` (6/6 ACs covered).

Tests

`tests/self-update.test.ts` (vitest): up-to-date, `--check` update-available, install-when-out-of-date, scoped vs unscoped registry override, ambient default (no flag), and registry-unreachable rejection. Mocks only the external edges (`node:child_process`, `@agent-ix/ix-ui-cli`). `make lint`/`make test`/`make build` green.

Consumer

`@agent-ix/quoin`'s `update` command consumes this (separate PR). Note: quoin must relock to the release that includes this export before its `update` works at runtime.

🤖 Generated with Claude Code

Adds runSelfUpdate({ packageName, currentVersion, header?, registry?, check? })
so any npm-distributed consuming CLI can offer an update/install-latest command
without re-implementing the registry query, version compare, and global install.
No oclif dependency -- callable from a plain dispatcher (e.g. quoin) as readily
as from a BaseCommand. Renders via ix-ui-cli and returns { updated, latest }.

Registry defaults to the ambient npm config (mirrors however the caller was
installed); a registry override is applied as the scope-specific
--<scope>:registry= flag for scoped packages, because a plain --registry is
silently ignored for a scoped package when an npmrc pins a @scope:registry.

Adds FR-023 + tests.md traceability.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kreneskyp kreneskyp requested a review from a team as a code owner June 20, 2026 20:47
@kreneskyp kreneskyp merged commit d2c8321 into main Jun 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant